<template>
  <div class="music-card">
    <div class="music-card__inner" >
      <div class="image-box p-rel" @click="toDetail(music)">
        <el-image class="image p-abs p-full" :src="music.picUrl">
          <img slot="placeholder" src="~@/assets/img/music-card-place.jpg" alt />
        </el-image>
        <div class="play-count p-abs p-full">
          <i class="iconfont icon-erji"></i>
          <span>{{music.playCount | changeCount}}</span>
        </div>
        <div class="play-btn p-abs" @click.stop="handleClick(music)">
          <i class="iconfont icon-bofang2"></i>
        </div>
      </div>
      <div class="name">
        <div  @click="toDetail(music)">{{music.name}}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    music: {
      type: Object,
      required: true
    }
  },
  methods: {
    toDetail(music) {
      this.$router.push({ path: '/playlist/detail?id='+music.id })
    },
    handleClick(music) {
      this.$store.dispatch('playPlaylist', music.id)
    }
  }
}
</script>

<style lang="scss">
.music-card {
  padding: 0 8px 10px;
  display: inline-block;
  vertical-align: middle;
  &__inner {
    width: 200px;
  }
  .image-box {
    cursor: pointer;
    border: 1px solid #bbb;
    height: 200px;
    width: 100%;
    font-size: 10px;
    color: #fff;
  }
  .image-box:hover .play-btn {
    display: block;
  }
  .play-count {
    text-align: right;
    padding: 0 6px;
    height: 20px;
    line-height: 20px;
    i,
    span {
      vertical-align: middle;
    }
    background-image: linear-gradient(
      to right,
      rgba(0, 0, 0, 0) 10%,
      rgba(0, 0, 0, 0.5) 100%
    );
  }
  .play-btn {
    .iconfont {
      font-size: 18px;
    }
    display: none;
    border-radius: 50%;
    bottom: 10px;
    right: 10px;
  }
  .play-btn:hover {
    color: var(--primary);
  }
  .name {
    padding-top: 4px;
    font-size: 14px;
    div {
      cursor: pointer;
    }
    height: 60px;
  }
}
</style>